﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LuaInterface;

public class ToluaTest01 : MonoBehaviour {

	
	void Start () {
        LuaState state = new LuaState();
        state.Start();

        state.AddSearchPath(Application.dataPath + "/Scripts/");
        state.DoFile("ToluaText01.lua");

        LuaFunction func = state.GetFunction("tb.Test");
        var result = func.Call(6);
        Debug.Log(result[0] + ":" + result[1]);

        
        Debug.Log(state["name"]);

        LuaTable tb = state.GetTable("tb");
        //LuaFunction tb_func = tb.GetLuaFunction("Test");
        //tb_func.Call(6);

        Debug.Log(tb["age"]);

        LuaTable mt = tb.GetMetaTable();
        Debug.Log(mt["name"]);

        LuaTable data = state.GetTable("data");
        object[] array = data.ToArray();
        foreach (var item in array)
        {
            Debug.Log(item);
        }
	}
	
	
}
